package Thread;

import java.util.concurrent.ThreadFactory;

/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2024/08/25
 * 线程工厂
 */
public class MyThreadFactory implements ThreadFactory {

    /**
     * Constructs a new unstarted {@code Thread} to run the given runnable.
     *
     * @param r a runnable to be executed by new thread instance
     * @return constructed thread, or {@code null} if the request to
     * create a thread is rejected
     * @see <a href="../../lang/Thread.html#inheritance">Inheritance when
     * creating threads</a>
     */
    @Override
    public Thread newThread(Runnable r) {
        /**
         *线程可以取名字
         */
        return new Thread(r,"线程1");
    }
}
